//q3.cpp
//The program takes a number in octal form and convert it to decimal
//
//Binyamin 22 december 2017
//-----------------------------------------------------------
#include <iostream>
#include <math.h>

using namespace std;

// 1. Prompt for an octal number.
// 2. Store the octal number.
// 3. Convert it to decimal.
// 4. print the decimal value.

int main()
{
	int num; // num - the number captured from the user.
	int length; // length - follows the length of the inserted number.
	int decimal; // the number in decimal form.

	//init
	decimal = 0;
	length = 0;

	//prompts
	cout << "Please enter a octal numer" << endl;
	cin >> num;

	//logic
	while(num>0)
	{
		decimal += (num % 10) * pow(8,length);
		num = num/10;
		length++;
	}
	cout << "The decimal form is " << decimal << endl;

	return 0;
}
//ouput
//Please enter a octal numer
//777
//The decimal form is 511
